home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / ColorSync / Sample Code / CSDemo 2.1 / CSDemoSources / winPictDocGetSet.c < prev    next >
Encoding:
Text File  |  1996-03-08  |  11.6 KB  |  446 lines  |  [TEXT/CWIE]

  1. // A pict file window
  2. //
  3. // David Hayward 
  4. // Developer Technical Support
  5. // AppleLink: DEVSUPPORT
  6. //
  7. // Copyrite 1995, Apple Computer,Inc
  8. //
  9. // This file contains the getter/setter routines for
  10. // the PictDocDataHdl fields of a pict file window.
  11. // 
  12. // 9/13/94    nick    first cut
  13. // 12/13/94    david    several modifications
  14.  
  15.  
  16. #include <QDOffScreen.h>
  17.  
  18. #include "win.h"
  19. #include "winPictDoc.h"
  20. #include "winPictDocGetSet.h"
  21. #include "colorsyncUtils.h"
  22.  
  23.  
  24. /*------------------------------------------------------------------------------*\
  25.     GetPictDocPict / SetPictDocPict
  26.  *------------------------------------------------------------------------------*
  27.         These routines get and set the Pict field of the PictDocDataHdl
  28.         of the winHandle.
  29. \*------------------------------------------------------------------------------*/
  30. PicHandle GetPictDocPict ( winHandle win, short which )
  31. {
  32.     PictDocDataHdl    data ;
  33.     data = (PictDocDataHdl) GetWinData ( win ) ;
  34.     if ( data==nil ) return nil ;
  35.     
  36.     switch (which)
  37.     {
  38.         case kOriginal:
  39.             return (**data).Pict ;
  40.             break ;
  41.         case kMatched:
  42.             return (**data).PictMatched ;
  43.             break ;
  44.         case kProofed:
  45.             return (**data).PictProofed ;
  46.             break ;
  47.         case kChecked:
  48.             return (**data).PictChecked ;
  49.             break ;
  50.     }
  51.     return nil ;
  52. }
  53. void SetPictDocPict ( winHandle win, short which, PicHandle thePict )
  54. {    
  55.     PictDocDataHdl    data ;
  56.     data = (PictDocDataHdl) GetWinData ( win ) ;
  57.     if ( data==nil ) return ;
  58.  
  59.     switch (which)
  60.     {
  61.         case kOriginal:
  62.             (**data).Pict = thePict ;
  63.             break ;
  64.         case kMatched:
  65.             (**data).PictMatched = thePict ;
  66.             break ;
  67.         case kProofed:
  68.             (**data).PictProofed = thePict ;
  69.             break ;
  70.         case kChecked:
  71.             (**data).PictChecked = thePict ;
  72.             break ;
  73.     }
  74. }
  75.  
  76.  
  77. /*------------------------------------------------------------------------------*\
  78.     GetPictDocNeedsUpdate / SetPictDocNeedsUpdate
  79.  *------------------------------------------------------------------------------*
  80.         These routines get and set the PictNeedsUpdate field of the PictDocDataHdl
  81.         of the winHandle.
  82. \*------------------------------------------------------------------------------*/
  83. Boolean GetPictDocNeedsUpdate ( winHandle win, short which )
  84. {
  85.     PictDocDataHdl    data ;
  86.     data = (PictDocDataHdl) GetWinData ( win ) ;
  87.     
  88.     switch (which)
  89.     {
  90.         case kOriginal:
  91.             return false ;
  92.             break ;
  93.         case kMatched:
  94.             return (**data).PictMatchedNeedsUpdate ;
  95.             break ;
  96.         case kProofed:
  97.             return (**data).PictProofedNeedsUpdate ;
  98.             break ;
  99.         case kChecked:
  100.             return (**data).PictCheckedNeedsUpdate ;
  101.             break ;
  102.     }
  103.     return false ;
  104. }
  105. void SetPictDocNeedsUpdate ( winHandle win, short which, Boolean b )
  106. {    
  107.     PictDocDataHdl    data ;
  108.     data = (PictDocDataHdl) GetWinData ( win ) ;
  109.     if ( data==nil ) return ;
  110.  
  111.     switch (which)
  112.     {
  113.         case kOriginal:
  114.             break ;
  115.         case kMatched:
  116.             (**data).PictMatchedNeedsUpdate = b ;
  117.             break ;
  118.         case kProofed:
  119.             (**data).PictProofedNeedsUpdate = b ;
  120.             break ;
  121.         case kChecked:
  122.             (**data).PictCheckedNeedsUpdate = b ;
  123.             break ;
  124.     }
  125. }
  126.  
  127.  
  128. /*------------------------------------------------------------------------------*\
  129.     GetPictDocDrawTime / SetPictDocDrawTime
  130.  *------------------------------------------------------------------------------*
  131.         These routines get and set the DrawTime field of the PictDocDataHdl
  132.         of the winHandle.
  133. \*------------------------------------------------------------------------------*/
  134. long GetPictDocDrawTime ( winHandle win, short which )
  135. {
  136.     PictDocDataHdl    data ;
  137.         data = (PictDocDataHdl) GetWinData ( win ) ;
  138.     if ( data==nil ) return nil;
  139.  
  140.     switch (which)
  141.     {
  142.         case kOriginal:
  143.             return 0L ;
  144.             break ;
  145.         case kMatched:
  146.             return (**data).MatchTime ;
  147.             break ;
  148.         case kProofed:
  149.             return (**data).ProofTime ;
  150.             break ;
  151.         case kChecked:
  152.             return (**data).CheckTime ;
  153.             break ;
  154.     }
  155.     return 0L ;
  156. }
  157. void SetPictDocDrawTime ( winHandle win, short which, long ticks )
  158. {    
  159.     PictDocDataHdl    data ;
  160.     data = (PictDocDataHdl) GetWinData ( win ) ;
  161.     if ( data==nil ) return ;
  162.  
  163.     switch (which)
  164.     {
  165.         case kOriginal:
  166.             break ;
  167.         case kMatched:
  168.             (**data).MatchTime = ticks ;
  169.             break ;
  170.         case kProofed:
  171.             (**data).ProofTime = ticks ;
  172.             break ;
  173.         case kChecked:
  174.             (**data).CheckTime = ticks ;
  175.             break ;
  176.     }
  177. }
  178.  
  179.  
  180.  
  181. /*------------------------------------------------------------------------------*\
  182.     GetPictDocPictRect / SetPictDocPictRect
  183.  *------------------------------------------------------------------------------*
  184.         These routines get and set the PictRect field of the PictDocDataHdl
  185.         of the winHandle.
  186. \*------------------------------------------------------------------------------*/
  187. Rect GetPictDocPictRect ( winHandle win )
  188. {
  189.     PictDocDataHdl    data ;
  190.     Rect            nilRect = {0,0,0,0} ;
  191.     data = (PictDocDataHdl) GetWinData ( win ) ;
  192.     if ( data==nil ) return nilRect;
  193.     return (**data).PictRect ;
  194. }
  195. void SetPictDocPictRect ( winHandle win, Rect theRect )
  196. {    
  197.     PictDocDataHdl    data ;
  198.     data = (PictDocDataHdl) GetWinData ( win ) ;
  199.     if ( data==nil ) return ;
  200.     (**data).PictRect = theRect ;
  201. }
  202.  
  203.  
  204. /*------------------------------------------------------------------------------*\
  205.     GetPictDocPaneRect / SetPictDocPaneRect
  206.  *------------------------------------------------------------------------------*
  207.         These routines get and set the PaneRect field of the PictDocDataHdl
  208.         of the winHandle.
  209. \*------------------------------------------------------------------------------*/
  210. Rect GetPictDocPaneRect ( winHandle win )
  211. {
  212.     PictDocDataHdl    data ;
  213.     Rect            nilRect = {0,0,0,0} ;
  214.     data = (PictDocDataHdl) GetWinData ( win ) ;
  215.     if ( data==nil ) return nilRect;
  216.     return (**data).PaneRect ;
  217. }
  218. void SetPictDocPaneRect ( winHandle win, Rect theRect )
  219. {    
  220.     PictDocDataHdl    data ;
  221.     data = (PictDocDataHdl) GetWinData ( win ) ;
  222.     if ( data==nil ) return ;
  223.     (**data).PaneRect = theRect ;
  224. }
  225.  
  226.  
  227.  
  228. /*------------------------------------------------------------------------------*\
  229.     GetPictDocPalette / SetPictDocPalette
  230.  *------------------------------------------------------------------------------*
  231.         These routines get and set the Palette field of the PictDocDataHdl
  232.         of the winHandle.
  233. \*------------------------------------------------------------------------------*/
  234. PaletteHandle GetPictDocPalette ( winHandle win )
  235. {
  236.     PictDocDataHdl    data ;
  237.     data = (PictDocDataHdl) GetWinData ( win ) ;
  238.     if ( data==nil ) return nil;
  239.     return (**data).Palette ;
  240. }
  241. void SetPictDocPalette ( winHandle win, PaletteHandle thePalette )
  242. {    
  243.     PictDocDataHdl    data ;
  244.     data = (PictDocDataHdl) GetWinData ( win ) ;
  245.     if ( data==nil ) return ;
  246.     (**data).Palette = thePalette ;
  247. }
  248.  
  249.  
  250.  
  251. /*------------------------------------------------------------------------------*\
  252.     GetPictDocCntl / SetPictDocCntl / GetPictDocCntlValue
  253.  *------------------------------------------------------------------------------*
  254.         These routines get and set the ControlHandle fields of the PictDocDataHdl
  255.         of the winHandle.
  256. \*------------------------------------------------------------------------------*/
  257. ControlHandle GetPictDocCntl ( winHandle win, short id )
  258. {
  259.     PictDocDataHdl    data ;
  260.     ControlHandle    cntl ;
  261.     
  262.     data = (PictDocDataHdl) GetWinData ( win ) ;
  263.     if ( data==nil ) return nil;
  264.     
  265.     switch (id)
  266.     {
  267.         case rPictDocHorzScrollID :
  268.             cntl = (**data).HorzScroll ;
  269.             break ;
  270.         case rPictDocVertScrollID :
  271.             cntl = (**data).VertScroll ;
  272.             break ;
  273.         case rPictDocMatchOnOffID :
  274.             cntl = (**data).MatchOnOff ;
  275.             break ;
  276.         case rPictDocMatchPopupID :
  277.             cntl = (**data).MatchPopup ;
  278.             break ;
  279.     }
  280.     return cntl ;
  281. }
  282. void SetPictDocCntl ( winHandle win, short id, ControlHandle cntl )
  283. {    
  284.     PictDocDataHdl    data ;
  285.  
  286.     data = (PictDocDataHdl) GetWinData ( win ) ;
  287.     if ( data==nil ) return ;
  288.     
  289.     switch (id)
  290.     {
  291.         case rPictDocHorzScrollID :
  292.             (**data).HorzScroll = cntl ;
  293.             break ;
  294.         case rPictDocVertScrollID :
  295.             (**data).VertScroll = cntl ;
  296.             break ;
  297.         case rPictDocMatchOnOffID :
  298.             (**data).MatchOnOff = cntl ;
  299.             break ;
  300.         case rPictDocMatchPopupID :
  301.             (**data).MatchPopup = cntl ;
  302.             break ;
  303.     }
  304. }
  305. short GetPictDocCntlValue ( winHandle win, short id )
  306. {
  307.     ControlHandle    cntl ;
  308.     cntl = GetPictDocCntl ( win, id ) ;
  309.     if ( cntl==nil ) return nil;
  310.     return GetControlValue( cntl ) ;
  311. }
  312. void SetPictDocCntlValue ( winHandle win, short id, short val )
  313. {
  314.     ControlHandle    cntl ;
  315.     cntl = GetPictDocCntl ( win, id ) ;
  316.     if ( cntl==nil ) return ;
  317.     SetControlValue( cntl, val ) ;
  318. }
  319.  
  320.  
  321.  
  322. /*------------------------------------------------------------------------------*\
  323.     GetPictDocProfile / SetPictDocProfile
  324.  *------------------------------------------------------------------------------*
  325.         These routines get and set the SrceProf, DestProf or PrevProf field of 
  326.         the PictDocDataHdl of the winHandle.  The which field is not validated
  327.         and must be kSrceProf, kDestProf, or kPrevProf
  328. \*------------------------------------------------------------------------------*/
  329. CMProfileRef GetPictDocProfile ( winHandle win, short which )
  330. {
  331.     PictDocDataHdl    data ;
  332.     CMProfileRef    prof = nil ;
  333.     
  334.     data = (PictDocDataHdl) GetWinData ( win ) ;
  335.     if ( data==nil ) return nil;
  336.     
  337.     switch (which)
  338.     {
  339.         case kSrceProf :
  340.             prof = (**data).SrceProf ;
  341.             break ;
  342.         case kDestProf :
  343.             prof = (**data).DestProf ;
  344.             break ;
  345.         case kPrevProf :
  346.             prof = (**data).PrevProf ;
  347.             break ;
  348.     }
  349.     return prof ;
  350. }
  351.  
  352. void SetPictDocProfile ( winHandle win, short which, CMProfileRef prof )
  353. {    
  354.     PictDocDataHdl        data ;
  355.     
  356.     data = (PictDocDataHdl) GetWinData ( win ) ;
  357.     if ( data==nil ) return ;
  358.     
  359.     HLock( (Handle)data ) ;
  360.     
  361.     switch (which)
  362.     {
  363.         case kSrceProf :
  364.             (**data).SrceProf = prof ;
  365.             break ;
  366.         case kDestProf :
  367.             (**data).DestProf = prof ;
  368.             break ;
  369.         case kPrevProf :
  370.             (**data).PrevProf = prof ;
  371.             break ;
  372.     }
  373. }
  374.  
  375.  
  376. /*------------------------------------------------------------------------------*\
  377.     GetPictDocProfList / SetPictDocProfList
  378.  *------------------------------------------------------------------------------*
  379.         These routines get and set the ProfList field of the ProfListDataHdl
  380.         of the winRecord.
  381. \*------------------------------------------------------------------------------*/
  382. ListHandle GetPictDocProfList ( winHandle win )
  383. {
  384.     PictDocDataHdl    data ;
  385.         data = (PictDocDataHdl) GetWinData ( win ) ;
  386.     if ( data==nil ) return nil;
  387.     return (**data).ProfList ;
  388. }
  389. void SetPictDocProfList ( winHandle win, ListHandle list )
  390. {    
  391.     PictDocDataHdl    data ;
  392.     data = (PictDocDataHdl) GetWinData ( win ) ;
  393.     if ( data==nil ) return ;
  394.     (**data).ProfList = list ;
  395. }
  396.  
  397.  
  398. /*------------------------------------------------------------------------------*\
  399.     GetPictDocListCount / SetPictDocListCount
  400.  *------------------------------------------------------------------------------*
  401.         These routines get and set the ListCount field of the ProfListDataHdl
  402.         of the winRecord.
  403. \*------------------------------------------------------------------------------*/
  404. unsigned long GetPictDocListCount ( winHandle win )
  405. {
  406.     PictDocDataHdl    data ;
  407.         data = (PictDocDataHdl) GetWinData ( win ) ;
  408.     if ( data==nil ) return nil;
  409.     return (**data).ListCount ;
  410. }
  411. void SetPictDocListCount ( winHandle win, unsigned long count )
  412. {    
  413.     PictDocDataHdl    data ;
  414.     data = (PictDocDataHdl) GetWinData ( win ) ;
  415.     if ( data==nil ) return ;
  416.     (**data).ListCount = count ;
  417. }
  418.  
  419.  
  420. /*------------------------------------------------------------------------------*\
  421.     GetPictDocDragZones / SetPictDocDragZones
  422.  *------------------------------------------------------------------------------*
  423.         These routines get and set the DragZones field of the DragZonesHdl
  424.         of the winHandle.
  425. \*------------------------------------------------------------------------------*/
  426. DragZonesHdl GetPictDocDragZones ( winHandle win )
  427. {
  428.     PictDocDataHdl    data ;
  429.     data = (PictDocDataHdl) GetWinData ( win ) ;
  430.     if ( data==nil ) return nil ;
  431.     
  432.     return (**data).DragZones ;
  433. }
  434. void SetPictDocDragZones ( winHandle win, DragZonesHdl theDragZones )
  435. {    
  436.     PictDocDataHdl    data ;
  437.     data = (PictDocDataHdl) GetWinData ( win ) ;
  438.     if ( data==nil ) return ;
  439.  
  440.     (**data).DragZones = theDragZones ;
  441. }
  442.  
  443.  
  444.  
  445.  
  446.